<!DOCTYPE html>
<html>
	<head>
		<title></title>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
		<link type="text/css" rel="stylesheet" href="./css/main.css">
	</head>
	<body>
		<div id="container"></div>
		
		<script type="module">

			import * as THREE from 'https://cdn.skypack.dev/three@0.135.0';
			import { OrbitControls } from 'https://cdn.skypack.dev/three@0.135.0/examples/jsm/controls/OrbitControls.js';

			let scene, renderer, camera;
			let textureCube;

			init();

			function init() {

				const container = document.getElementById( 'container' );

				scene = new THREE.Scene();
				scene.background = new THREE.Color( 0xa0a0a0 );
				
				const cubeTextureLoader = new THREE.CubeTextureLoader();
				cubeTextureLoader.setPath( '/tuPian/' );
				textureCube = cubeTextureLoader.load( [ '-x.jpg', 'x.jpg', 'y.jpg', '-y.jpg', 'z.jpg', '-z.jpg' ] );
				textureCube.encoding = THREE.sRGBEncoding;
				scene.background = textureCube;

				renderer = new THREE.WebGLRenderer( { antialias: true } );
				renderer.setPixelRatio( window.devicePixelRatio );
				renderer.setSize( window.innerWidth, window.innerHeight );
				renderer.outputEncoding = THREE.sRGBEncoding;
				renderer.shadowMap.enabled = true;
				container.appendChild( renderer.domElement );

				// camera
				camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 100 );
				camera.position.set( - 1, 2, 3 );

				const controls = new OrbitControls( camera, renderer.domElement );
				controls.enablePan = false;
				controls.enableZoom = true;
				controls.target.set( 0, 1, 0 );
				controls.update();

				window.addEventListener( 'resize', onWindowResize );

			}


			function onWindowResize() {

				camera.aspect = window.innerWidth / window.innerHeight;
				camera.updateProjectionMatrix();

				renderer.setSize( window.innerWidth, window.innerHeight );

			}

			function animate() {
				requestAnimationFrame( animate );
				renderer.render( scene, camera );
			}
			animate()
		</script>

	</body>
</html>